package cc.eddic.pratice.programmingparadigms.emp03objlist.impl;

import cc.eddic.pratice.programmingparadigms.Result;
import cc.eddic.pratice.programmingparadigms.ResultComparator;
import cc.eddic.pratice.programmingparadigms.ResultPredicate;
import cc.eddic.pratice.programmingparadigms.emp02list.ResultList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectComparator;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectPredicate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResultListLxImpl extends ObjectList implements ResultList {
    private static final Logger log = LoggerFactory.getLogger(ResultListGcsImpl.class);

    public ResultListLxImpl() {
    }

    public ResultListLxImpl(int capacity) {
        super(capacity);
    }

    @Override
    public void add(Result result) {
        super.add(result);
    }

    @Override
    public Result get(int index) {

        return (Result) super.get(index);
    }

    @Override
    public Result findByGender(String gender) {
        return findByKey(gender);
    }

    @Override
    public Result findByDepartment(String department) {
        return findByDepartment(department);
    }

    @Override
    public Result findByJobTitle(String jobTitle) {
        return findByJobTitle(jobTitle);
    }

    @Override
    public Result find(ResultPredicate predicate) {
        return (Result) super.find(new ObjectPredicate() {
            @Override
            public boolean test(Object obj) {
                return predicate.test((Result) obj);
            }
        });
    }

    @Override
    public void sort(ResultComparator comparator) {
        super.sort(new ObjectComparator() {
            @Override
            public int compare(Object o1, Object o2) {
                return comparator.compare((Result) o1,(Result) o2);
            }
        });
    }
}
